/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Cong
 */
@Entity
@Table(name = "nhanvien")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Nhanvien.findAll", query = "SELECT n FROM Nhanvien n"),
    @NamedQuery(name = "Nhanvien.findById", query = "SELECT n FROM Nhanvien n WHERE n.id = :id"),
    @NamedQuery(name = "Nhanvien.findByTendangnhap", query = "SELECT n FROM Nhanvien n WHERE n.tendangnhap = :tendangnhap"),
    @NamedQuery(name = "Nhanvien.findByMatkhau", query = "SELECT n FROM Nhanvien n WHERE n.matkhau = :matkhau"),
    @NamedQuery(name = "Nhanvien.findByEmail", query = "SELECT n FROM Nhanvien n WHERE n.email = :email"),
    @NamedQuery(name = "Nhanvien.findByHoten", query = "SELECT n FROM Nhanvien n WHERE n.hoten = :hoten"),
    @NamedQuery(name = "Nhanvien.findBySodienthoai", query = "SELECT n FROM Nhanvien n WHERE n.sodienthoai = :sodienthoai"),
    @NamedQuery(name = "Nhanvien.findByNgaysinh", query = "SELECT n FROM Nhanvien n WHERE n.ngaysinh = :ngaysinh"),
    @NamedQuery(name = "Nhanvien.findByNgaytaotaikhoan", query = "SELECT n FROM Nhanvien n WHERE n.ngaytaotaikhoan = :ngaytaotaikhoan")})
public class Nhanvien implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Column(name = "tendangnhap")
    private String tendangnhap;
    @Column(name = "matkhau")
    private String matkhau;
    @Basic(optional = false)
    @Column(name = "email")
    private String email;
    @Basic(optional = false)
    @Column(name = "hoten")
    private String hoten;
    @Basic(optional = false)
    @Column(name = "sodienthoai")
    private String sodienthoai;
    @Column(name = "ngaysinh")
    @Temporal(TemporalType.TIMESTAMP)
    private Date ngaysinh;
    @Basic(optional = false)
    @Column(name = "ngaytaotaikhoan")
    @Temporal(TemporalType.TIMESTAMP)
    private Date ngaytaotaikhoan;
    @OneToMany(mappedBy = "nguoitaotaikhoan")
    private Collection<Nhanvien> nhanvienCollection;
    @JoinColumn(name = "nguoitaotaikhoan", referencedColumnName = "id")
    @ManyToOne
    private Nhanvien nguoitaotaikhoan;
    @JoinColumn(name = "id_cuahang", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Cuahang idCuahang;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "nguoitaotaikhoan")
    private Collection<Khachhang> khachhangCollection;

    public Nhanvien() {
    }

    public Nhanvien(Long id) {
        this.id = id;
    }

    public Nhanvien(Long id, String email, String hoten, String sodienthoai, Date ngaytaotaikhoan) {
        this.id = id;
        this.email = email;
        this.hoten = hoten;
        this.sodienthoai = sodienthoai;
        this.ngaytaotaikhoan = ngaytaotaikhoan;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getTendangnhap() {
        return tendangnhap;
    }

    public void setTendangnhap(String tendangnhap) {
        this.tendangnhap = tendangnhap;
    }

    public String getMatkhau() {
        return matkhau;
    }

    public void setMatkhau(String matkhau) {
        this.matkhau = matkhau;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getHoten() {
        return hoten;
    }

    public void setHoten(String hoten) {
        this.hoten = hoten;
    }

    public String getSodienthoai() {
        return sodienthoai;
    }

    public void setSodienthoai(String sodienthoai) {
        this.sodienthoai = sodienthoai;
    }

    public Date getNgaysinh() {
        return ngaysinh;
    }

    public void setNgaysinh(Date ngaysinh) {
        this.ngaysinh = ngaysinh;
    }

    public Date getNgaytaotaikhoan() {
        return ngaytaotaikhoan;
    }

    public void setNgaytaotaikhoan(Date ngaytaotaikhoan) {
        this.ngaytaotaikhoan = ngaytaotaikhoan;
    }

    @XmlTransient
    public Collection<Nhanvien> getNhanvienCollection() {
        return nhanvienCollection;
    }

    public void setNhanvienCollection(Collection<Nhanvien> nhanvienCollection) {
        this.nhanvienCollection = nhanvienCollection;
    }

    public Nhanvien getNguoitaotaikhoan() {
        return nguoitaotaikhoan;
    }

    public void setNguoitaotaikhoan(Nhanvien nguoitaotaikhoan) {
        this.nguoitaotaikhoan = nguoitaotaikhoan;
    }

    public Cuahang getIdCuahang() {
        return idCuahang;
    }

    public void setIdCuahang(Cuahang idCuahang) {
        this.idCuahang = idCuahang;
    }

    @XmlTransient
    public Collection<Khachhang> getKhachhangCollection() {
        return khachhangCollection;
    }

    public void setKhachhangCollection(Collection<Khachhang> khachhangCollection) {
        this.khachhangCollection = khachhangCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Nhanvien)) {
            return false;
        }
        Nhanvien other = (Nhanvien) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "gui.Nhanvien[ id=" + id + " ]";
    }
    
}
